package com.iwhalecloud.bss.kite.cucc.service.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.iwhalecloud.bss.kite.common.callclient.CallClient;
import com.iwhalecloud.bss.kite.common.callclient.constant.CallClientEnum;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;

import com.ztesoft.bss.common.util.PropertiesUtil;
import com.ztesoft.bss.cust.infield.CustRequestObjectField;
import com.ztesoft.bss.svcability.aggobj.SvcCont;

/**
 * 功能描述：调用接口工具类
 *
 * @author yang.kuowei
 * @version 1.0
 * @date 2020/02/19 10:17
 */
public class CallClientUtils {
    /**
     * 调用接口的方式
     */
    public static final String MODE;

    static {
        String property = PropertiesUtil.getProperty("interface.call.mode");
        MODE = KiteStringUtils.isNotEmpty(property) ? property : "hsf";
    }

    /**
     * 根据客户id查询客户信息，包括证件信息
     *
     * @param custId 客户id
     * @return
     *         <p>
     *         select a.cust_id, a.cust_name, a.cust_number, a.cust_type, a.cust_addr cust_address, a.handle_cust_id,
     *         a.state, a.status_cd, a.cust_order_id, a.ini_password from customer a where a.cust_id =? and state =?;
     *         </p>
     *         <p>
     *         select pc.cert_type certi_type, pc.cert_num certi_number, pc.cert_addr certi_address from party_cert pc
     *         where pc.party_cert_id =?;
     *         </p>
     */
    public static Map getCustMapByCustId(String custId) {
        Map<String, Object> busiMap = new HashMap<>();
        List<String> querySqlParams = new ArrayList<>();
        querySqlParams.add(custId);
        querySqlParams.add("1000");
        busiMap.put(CustRequestObjectField.QUERY_SQL_PARAM, querySqlParams);
        SvcCont custSvcCont = CallClient.callRemoteService(CallClientEnum.QUERY_QRYCUSTCERTINCLSTATE, busiMap);
        return custSvcCont.getResultObject().getData();
    }

    public static boolean callByHttp() {
        return KiteStringUtils.isEqual("http", MODE);
    }

}
